package cn.tedu.charging.device.controller;

import cn.tedu.charging.device.service.StationService;
import cn.tedu.common.pojo.JsonResult;
import cn.tedu.common.pojo.vo.StationInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/station")
public class StationController {
    @Autowired
    private StationService stationService;
    @GetMapping("/near/info")
    public JsonResult<StationInfoVO> getNearStationList(Double longitude, Double latitude, Double radius) {
        log.debug("获取附近场站信息入参{},{},{}",longitude,latitude,radius);
        List<StationInfoVO> nearStationList =
                stationService.getNearStationList(longitude, latitude, radius);
        log.debug("获取附近场站信息出参:{}",nearStationList);
        return JsonResult.ok(nearStationList);
    }

    @GetMapping("/info/{id}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("id") Integer id) {
        log.debug("获取指定场站信息的入参:{}",id);
        StationInfoVO stationInfoVO = stationService.getStationInfo(id);
        log.debug("获取指定场站信息的出参:{}",stationInfoVO);
        return JsonResult.ok(stationInfoVO);
    }
}
